home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / include / stubs.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  1.8 KB  |  80 lines

  1.  
  2. /** \file stubs.h interface to platform-dependent functions
  3.  */
  4.  
  5. #ifndef __stubs_h__
  6. #define __stubs_h__
  7.  
  8. #include "lisptype.h"
  9.  
  10. /** Simple function that determines if two strings are equal,
  11.   should be defined in stubs.inl */
  12. //inline LispInt StrEqual(LispCharPtr ptr1, LispCharPtr ptr2);
  13.  
  14.  
  15. #ifdef NO_GLOBALS
  16.   LispCharPtr PlatAlloc(LispInt aNrBytes);
  17.   LispCharPtr PlatReAlloc(LispCharPtr aOrig, LispInt aNrBytes);
  18.   void PlatFree(LispCharPtr aOrig);
  19.   #define NEW new 
  20. #else
  21.  
  22. #ifdef DEBUG_MODE
  23. #include "debugmem.h"
  24.   #define PlatAlloc(nr)        (LispCharPtr)YacasMallocPrivate((size_t)nr,__FILE__,__LINE__)
  25.   #define PlatReAlloc(orig,nr) (LispCharPtr)YacasReAllocPrivate((void*)orig,(size_t)nr,__FILE__,__LINE__)
  26.   #define PlatFree(orig)       YacasFreePrivate((void*)orig)
  27.   #define NEW new (__FILE__,__LINE__)
  28. #else
  29.   void *PlatObAlloc(size_t nbytes);
  30.   void PlatObFree(void *p);
  31.   void *PlatObReAlloc(void *p, size_t nbytes);
  32.   #define PlatAlloc(nr)        (LispCharPtr)PlatObAlloc((size_t)nr)
  33.   #define PlatReAlloc(orig,nr) (LispCharPtr)PlatObReAlloc((void*)orig,(size_t)nr)
  34.   #define PlatFree(orig)       PlatObFree((void*)orig)
  35.   #define NEW new 
  36. #endif
  37.  
  38.  
  39. #ifdef YACAS_DEBUG
  40. #include <stdio.h>
  41. inline void* operator new(size_t size)
  42. {
  43.     int* ptr = NULL;
  44.     *ptr = 1;
  45.     printf("new called\n");
  46.     return PlatAlloc(size);
  47. }
  48. inline void* operator new[](size_t size)
  49. {
  50.     int* ptr = NULL;
  51.     *ptr = 1;
  52.     printf("new called\n");
  53.     return PlatAlloc(size);
  54. }
  55. inline void operator delete(void* object)
  56. {
  57.     int* ptr = NULL;
  58.     *ptr = 1;
  59.     printf("delete called\n");
  60.     PlatFree((LispCharPtr)object);
  61. }
  62. inline void operator delete[](void* object)
  63. {
  64.     int* ptr = NULL;
  65.     *ptr = 1;
  66.     printf("delete called\n");
  67.     PlatFree((LispCharPtr)object);
  68. }
  69.  
  70. #endif
  71.  
  72.  
  73. #endif
  74.  
  75. #include "stubs.inl"
  76.  
  77. #endif
  78.  
  79.  
  80.